﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using Newtonsoft.Json.Linq;

using CanDoo;
using CanDoo.Core;
using CanDoo.Data;
using CanDoo.Web;
using CanDoo.FineUI;
using CanDoo.Core.Web;
using CanDoo.Extensions;
using CanDoo.Oil.Core.Models;
using CanDoo.Oil.Core.Contracts;
using FineUIPro;

namespace CanDoo.Oil.WebApp.UserControls
{
    public partial class SelectInStore : UserControlBase<IInStoreContract, InStore>
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SelectInStoreControl_GridList.EnableMultiSelect = EnableMultiSelect;
                SelectInStoreControl_GridList.KeepCurrentSelection = EnableMultiSelect;
                InitGrid();
            }
        }

        protected override void InitControls()
        {
            this._GridList = SelectInStoreControl_GridList;
            this._SearchKey = SearchKey;
        }

        protected override void SetSelector()
        {
            this.Selector = p => new
            {
                p.Code,
                p.InOrder,
                p.InOrderId,
                p.InStoreDate,
                p.User,
                p.UserId,
                p.Supplier,
                p.SupplierId,
                p.Warehouse,
                p.WarehouseId,
                p.Num,
                p.Money,
                p.CashPayed,
                p.WaitPay,
                p.PaymentDays,
                p.AppointPayDate,
                p.Remark,
                p.Id,
                p.Name
            };
        }


        protected override void Search()
        {
            var key = SearchKey.GetValue();
            if(key.IsNullOrEmpty() == false)
            {
                Filter = Filter.And(p => p.Name.Contains(key));
            }
            //base.Search();
        }
    }
}

